<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>文章列表</title>
    <!-- 必须的 meta 标签 -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap 的 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
          integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
    <!--导入jquery-->
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

    <style>
        .nav {
            margin-top: 10px;
            margin-left: 20px;

        }

        .content {
            margin-left: 20px;
            margin-top: 10px;

        }

        .nav-item {
            border-radius: 5px;
            background-color: #D1E0CA;
        }

        .nav-link {
            text-align: center;
            color: #2b669a;
        }

        .nav-item, .nav-link {
            width: 200px;
            height: 60px;
            line-height: 40px;
            font-size: 20px;
        }
    </style>

</head>
<script>

</script>
<body>
<div>
    <ul class="nav nav-pills nav-pills-custom">
        <li class="nav-item ">
            <a class="nav-link active"  href="${pageContext.request.contextPath}/admin/pageQuery">文章列表</a>
        </li>
        <li class="nav-item">
            <a class="nav-link"  href="${pageContext.request.contextPath}/admin/pageQueryForCategory">文章分类</a>
        </li>
        <li class="nav-item">
            <a class="nav-link"  href="${pageContext.request.contextPath}/admin/pageQueryForLabel">文章标签</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" id="previousPage" href="${pageContext.request.contextPath}/manage.jsp">返回上一页</a>
        </li>
    </ul>
</div>


<div id="articleList" class="content">
    <form id="form_summit">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success" style="background-color: #1A92FE;">
                <th>ID</th>
                <th>作者</th>
                <th>标题</th>
                <th style="margin-right: 20px">类型</th>
                <th>发布时间</th>
                <th>更新时间</th>
                <th>浏览量</th>
            </tr>
            <c:forEach items="${list}" var="article" varStatus="s">
            <tr>
                <td>${s.count}</td>
                <td>${article.username}</td>
                <td>${article.title}</td>
                <td>${article.cname}</td>
                <td>${article.createTime}</td>
                <td>${article.modifyTime}</td>
                <td>${article.browserNum}</td>
                </c:forEach>
            </tr>
        </table>
    </form>
</div>
<div>
    <nav>
        <ul class="pagination">

            <div>
    <span style="font-size: 25px; margin-left: 5px;">
        共<span style="color: blue;">${pb.totalCount}</span>条记录，共<span style="color: blue;">${pb.totalPage}</span>页
    </span>
            </div>

            <br>

            <li class="page-item">
                <a class="page-link"
                   href="${pageContext.request.contextPath}/admin/pageQuery?currentPage=${pb.currentPage - 1}"
                   aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <ul class="pagination">
                <c:set var="previousPages" value="${pb.currentPage - 5}" />
                <c:set var="nextPages" value="${pb.currentPage + 4}" />

                <c:if test="${previousPages < 1}">
                    <c:set var="previousPages" value="1" />
                </c:if>

                <c:if test="${pb.totalPage < nextPages}">
                    <c:set var="nextPages" value="${pb.totalPage}" />
                </c:if>

                <c:forEach begin="${previousPages}" end="${nextPages}" var="i">
                    <c:if test="${pb.currentPage == i}">
                        <li class="page-item active">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/admin/pageQuery?currentPage=${i}&rows=10">${i}</a>
                        </li>
                    </c:if>
                    <c:if test="${pb.currentPage != i}">
                        <li class="page-item">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/admin/pageQuery?currentPage=${i}&rows=10">${i}</a>
                        </li>
                    </c:if>
                </c:forEach>

                <li class="page-item">
                    <a class="page-link"
                       href="${pageContext.request.contextPath}/admin/pageQuery?currentPage=${pb.currentPage + 1}&rows=10"
                       aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </ul>
    </nav>
</div>
</div>

</body>
</html>
